package cmp.dataholders;

public class AAStatistics 
{

	static public boolean isCommonAcidSub(char chAcid1, char chAcid2) {
		// Return true anytime the BLOSUM62 matrix value is >= 1. This seems to
		// be how blast places '+' for a likely substitution in it's alignment.
		if (chAcid1 == chAcid2)
			return true;

		switch (chAcid1) {
		case AMINO_Glx:
			return (chAcid2 == AMINO_Asp || chAcid2 == AMINO_Gln
					|| chAcid2 == AMINO_Glu || chAcid2 == AMINO_Lys
					|| chAcid2 == AMINO_Asx);
		case AMINO_Asx:
			return  (chAcid2 == AMINO_Asn || chAcid2 == AMINO_Asp
					|| chAcid2 == AMINO_Glu || chAcid2 == AMINO_Glx);
		case AMINO_Ala:
			return (chAcid2 == AMINO_Ser);
		case AMINO_Arg:
			return (chAcid2 == AMINO_Gln || chAcid2 == AMINO_Lys);
		case AMINO_Asn:
			return chAcid2 == AMINO_Asp || chAcid2 == AMINO_His
					|| chAcid2 == AMINO_Ser || chAcid2 == AMINO_Asx;
		case AMINO_Asp:
			return chAcid2 == AMINO_Asn || chAcid2 == AMINO_Glu
					|| chAcid2 == AMINO_Asx || chAcid2 == AMINO_Glx;
		case AMINO_Gln:
			return chAcid2 == AMINO_Arg || chAcid2 == AMINO_Glu
					|| chAcid2 == AMINO_Lys || chAcid2 == AMINO_Glx;
		case AMINO_Glu:
			return chAcid2 == AMINO_Asp || chAcid2 == AMINO_Gln
					|| chAcid2 == AMINO_Lys || chAcid2 == AMINO_Asx
					|| chAcid2 == AMINO_Glx;
		case AMINO_His:
			return chAcid2 == AMINO_Asn || chAcid2 == AMINO_Tyr;
		case AMINO_Ile:
			return chAcid2 == AMINO_Leu || chAcid2 == AMINO_Met
					|| chAcid2 == AMINO_Val;
		case AMINO_Leu:
			return chAcid2 == AMINO_Ile || chAcid2 == AMINO_Met
					|| chAcid2 == AMINO_Val;
		case AMINO_Lys:
			return chAcid2 == AMINO_Arg || chAcid2 == AMINO_Gln
					|| chAcid2 == AMINO_Glu || chAcid2 == AMINO_Glx;
		case AMINO_Met:
			return chAcid2 == AMINO_Ile || chAcid2 == AMINO_Leu
					|| chAcid2 == AMINO_Val;
		case AMINO_Phe:
			return chAcid2 == AMINO_Trp || chAcid2 == AMINO_Tyr;
		case AMINO_Ser:
			return chAcid2 == AMINO_Ala || chAcid2 == AMINO_Asn
					|| chAcid2 == AMINO_Thr;
		case AMINO_Thr:
			return chAcid2 == AMINO_Ser;
		case AMINO_Trp:
			return chAcid2 == AMINO_Phe || chAcid2 == AMINO_Tyr;
		case AMINO_Tyr:
			return chAcid2 == AMINO_His || chAcid2 == AMINO_Phe
					|| chAcid2 == AMINO_Trp;
		case AMINO_Val:
			return chAcid2 == AMINO_Ile || chAcid2 == AMINO_Leu
					|| chAcid2 == AMINO_Met;
		default:
			return false;
		}
	}

	// Constants for the letters representing amino acids
	static private final char AMINO_Phe = 'F';
	static private final char AMINO_Ile = 'I';
	static private final char AMINO_Met = 'M';
	static private final char AMINO_Leu = 'L';
	static private final char AMINO_Val = 'V';
//	static private final char AMINO_Pro = 'P';
	static private final char AMINO_Ser = 'S';
	static private final char AMINO_Thr = 'T';
	static private final char AMINO_Ala = 'A';
	static private final char AMINO_Tyr = 'Y';
//	static private final char AMINO_Stop = '*';
	static private final char AMINO_Gln = 'Q';
	static private final char AMINO_Lys = 'K';
	static private final char AMINO_Glu = 'E';
	static private final char AMINO_Trp = 'W';
//	static private final char AMINO_Gly = 'G';
	static private final char AMINO_His = 'H';
	static private final char AMINO_Asn = 'N';
	static private final char AMINO_Asp = 'D';
//	static private final char AMINO_Cys = 'C';
	static private final char AMINO_Arg = 'R';
	static public final char AMINO_Glx = 'Z';
	static public final char AMINO_Asx = 'B';
	static public final char AMINO_Amiguous = 'X';
}
